#include <stdio.h>

char trans(int c)
{
	switch(c){
		case 0: return ' ';
		case 1: return '.';
		case 2: return 'x';
		case 3: return 'W';
		default: return '=';
	}
}

int main(){
	int n=0;	// num of cases
	int DNA[10]={};
	int dishes[42]={0,[41]=0};
	int temp[42];
	int i,j;
	
	
	// read in test cases
	scanf("%d",&n);
	
	// * in these cases
	while(n--){

	// initialize the necessary values
		for(i=0;i<10;i++)	scanf("%d",DNA+i);// read in DNA pattern
		memset(temp,0,sizeof(temp));	temp[20]=1;


	// simulate and output
		for(j=0;j<50;j++)
		{
			for(i=1;i<=40;i++)	{dishes[i]=temp[i];printf("%c",trans(dishes[i]));}
			for(i=1;i<=40;i++)	temp[i]=DNA[dishes[i]+dishes[i+1]+dishes[i-1]];
			putchar('\n');
		}
		putchar('\n');
	}
	
	return 0;
}
